package com.alliky.user.ui.viewmodel;

import android.graphics.drawable.Drawable;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.databinding.ObservableField;

import com.alliky.core.entity.vo.GoodsVO;
import com.alliky.core.base.ItemViewModel;
import com.alliky.core.binding.command.BindingCommand;
import com.alliky.core.bus.RxMessager;
import com.alliky.user.R;

/**
 * @Author: wxianing
 * @CreateDate: 2022/8/1 21:44
 * @Description: java类作用描述
 */
public class RecommendItemViewModel extends ItemViewModel<MyViewModel> {

    public ObservableField<GoodsVO> mGoodsVO = new ObservableField<>();
    public Drawable mDrawable;

    public RecommendItemViewModel(@NonNull MyViewModel viewModel,GoodsVO goodsVO) {
        super(viewModel);
        this.mGoodsVO.set(goodsVO);
        mDrawable = ContextCompat.getDrawable(viewModel.getApplication(), R.mipmap.icon_default);
    }

    //item点击事件
    public BindingCommand onItemClick = new BindingCommand(() -> {
        GoodsVO goodsVO1 = mGoodsVO.get();
        RxMessager.getDefault().send(goodsVO1.getGoods_name(), "1111");
    });
}
